package com.data.center.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.data.center.annotation.ForeignInfo;
import com.data.center.service.impl.PersonServiceImpl;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

@Data
@TableName("person")
public class Person {

    @TableId
    private String personId;

    private String name;
    private String nationalIdType;
    private String nationalId;
    private String stid;
    private String gender;
    private Date dob;
    private String ethnicGroup;
    private String nationality;
    private String birthplace;
    private String politicalAffiliation;
    private String idPhoto;
    private String lifePhoto;

    @ForeignInfo(targetClass = Organization.class,
            foreignKey = "organizationId",
            serviceClass = PersonServiceImpl.class,
            searchByForeignKeyMethodName = "searchByAffiliation",
            deleteByForeignKeyMethodName = "deleteByAffiliation",
            mergeByForeignKeyMethodName = "mergeByAffiliation")
    private String affiliation;

    private String department;
    private String positionRank;
    private String position;
    private String title;

    @ForeignInfo(targetClass = Organization.class,
            foreignKey = "organizationId",
            serviceClass = PersonServiceImpl.class,
            searchByForeignKeyMethodName = "searchByGraduation",
            deleteByForeignKeyMethodName = "deleteByGraduation",
            mergeByForeignKeyMethodName = "mergeByGraduation")
    private String graduation;

    private String major;
    private String education;
    private String degree;
    private String disciplines;
    private String category;
    private String keywords;
    private String division;
    private String address;
    private String postCode;
    private String mobile;
    private String fax;
    private String email;
    private String phone;
    private String contactName;
    private String contactMobile;
    private String contactPhone;
    private String account;
    private String bank;
    private String branch;
    private String accountOwner;
    private String authentication;
    private String authenticator;
    private Date authenticateTime;
    private String status;
    private String modifier;
    private Date lastModifiedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Person)) return false;
        Person person = (Person) o;
        return Objects.equals(getPersonId(), person.getPersonId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getPersonId());
    }
}